home *** CD-ROM | disk | FTP | other *** search
/ Free Software Collection: Marty 1 / FM Towns Marty 1 Free Software Collection.iso / joke / fugaku / source / fugaku.c next >
Text File  |  1993-11-11  |  8KB  |  400 lines

  1. /*
  2.         ハイパー富嶽三十六景
  3.  
  4.         Version history : 1992-01-07  version 0.01
  5.  
  6.         Last update     : 1992-02-29  version 0.10
  7. */
  8.  
  9.  
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <string.h>
  13. #include <jctype.h>
  14. #include <alldef.h>
  15. #include "kygload.c"  /*  ver.0.10  */
  16.  
  17.  
  18. char    egbwork[ 1536 ];
  19. char    mousework[ 4096 ];
  20.  
  21. short    mouseX;
  22. short    mouseY;
  23. char    button;
  24. char    buttonStack;
  25.  
  26. char *fn[] =
  27. {    "logo.kyg",
  28.     "title.kyg",
  29.     "korega.kyg",
  30.     "fuji2.kyg",
  31.     "zyoou.kyg",
  32.     "sakasa.kyg",
  33.     "telepo.kyg",
  34.     "ufo.kyg",
  35.     "hosi.kyg",
  36.     "sentai.kyg",
  37.     "yukio.kyg",
  38.     "sinrei.kyg",
  39.     "sakkyoku.kyg",
  40.     "zyukai.kyg",
  41.     "50on.kyg",
  42.     "5byou.kyg",
  43.     "tendou.kyg",
  44.     "cyoukan.kyg",
  45.     "13kin.kyg",
  46.     "fcyaku.kyg",
  47.     "sagase.kyg",
  48.     "goko.kyg",
  49.     "robo.kyg",
  50.     "yamai.kyg",
  51.     "saigo.kyg",
  52.     "seizin.kyg",
  53.     "usi.kyg",
  54.     "cyou.kyg",
  55.     "isi.kyg",
  56.     "fujfuj.kyg",
  57.     "houkai.kyg",
  58.     "siki.kyg",
  59.     "sissou.kyg",
  60.     "susono.kyg",
  61.     "nisefuji.kyg",
  62.     "fujimi.kyg",
  63.     "tubo.kyg",
  64.     "service.kyg",
  65.     "end.kyg"
  66. };
  67.  
  68. char *title[] =
  69. {    "LOGO",
  70.     "Title",
  71.     "これが富士山だ!!",
  72.     "怒濤の富士つ-",
  73.     "富士女王様",
  74.     "絶景、逆さ富士",
  75.     "必殺、富士テレポーテーション",
  76.     "謎の円盤UFO",
  77.     "目指せ!富士の星!!",
  78.     "山岳戦隊 フジレンジャー",
  79.     "川口浩 探検隊シリーズ、富士山頂に巨大雪男を発見!",
  80.     "緊急発表、これが心霊写真だ!",
  81.     "ヨハン・セバスチャン・フジ・バッハ",
  82.     "真実の報道、富士の樹海",
  83.     "富士五十音",
  84.     "富士山大爆発五秒前!",
  85.     "富士中心説 【アルマゲストより】",
  86.     "富士鳥瞰図",
  87.     "13日の富士曜日",
  88.     "カメラが捕らえた、不時着の決定的瞬間!",
  89.     "フージィーを探せ",
  90.     "名所名跡の旅 富士五湖",
  91.     "富士ロボの逆襲",
  92.     "不治の病",
  93.     "富士の最後",
  94.     "怪獣大図鑑 フジ星人",
  95.     "富士と牛",
  96.     "大横綱 千代の富士",
  97.     "白い巨塔",
  98.     "怪獣フジフジ地帯",
  99.     "富士山崩壊!",
  100.     "ふじ式",
  101.     "疾走!",
  102.     "富士の裾野",
  103.     "偽フジ登場、敵か味方か?",
  104.     "戦慄、不死身の男",
  105.     "海洋生物シリーズ、ふじつぼ",
  106.     "過剰なサーヴィス",
  107.     "End"
  108. };
  109.  
  110.  
  111. void fugaku( void );
  112. void print( int x, int y, char *s, int color );
  113. void line( int x1, int y1, int x2, int y2, int func, int color, int bf );
  114. void clear( int x1, int y1, int x2, int y2, int page, int mode );
  115. void egbInit( void );
  116. void mouseInit( void );
  117. void graphicDisp( char *fn, int ef, int wf );
  118. void paletteChange( int n, int g, int r, int b );
  119. void fade( int pn, int mode );
  120. void triggerOffWait( void );
  121. void wait( unsigned long n, int cf );
  122. void fugakuExit( void );
  123.  
  124.  
  125. void main( void )
  126. {
  127.     egbInit();
  128.     mouseInit();
  129.  
  130.     fugaku();
  131.  
  132.     fugakuExit();
  133. }
  134.  
  135.  
  136. void fugaku( void )
  137. {
  138.     int n;
  139.  
  140.     graphicDisp( fn[ 0 ], ON, OFF );
  141.     wait( 0x7000, 0 );
  142.  
  143.     for( n = 1; n < 39; ++n )
  144.     {
  145.         if( n != 1 && n != 38 )
  146.         {
  147.             print( ( 640 - strlen( title[ n ] ) * 8 ) / 2, 230, title[ n ], 15 );
  148.             wait( 0x8000, 0 );
  149. /*            fade( 15, 1 );
  150.             EGB_clearScreen( egbwork );
  151.             paletteChange( 15, 255, 255, 255 );
  152. */
  153.         }
  154.         graphicDisp( fn[ n ], ON, OFF );
  155.         wait( 0x20000, 0 );
  156.         EGB_clearScreen( egbwork );
  157.         clear( 0, 0, 319, 239, 1, ( n == 38 ) ? 0 : 1 );
  158.         wait( 0x1000, 0 );
  159.     }
  160. }
  161.  
  162.  
  163. void print( int x, int y, char *s, int color )
  164. {
  165.     int i;
  166.     int code;
  167.     char parea[ 256 ];
  168.  
  169.     EGB_writeMode( egbwork, 0 );
  170.     EGB_color( egbwork, 0, color );
  171.  
  172.     WORD( parea + 0 ) = x;
  173.     WORD( parea + 2 ) = y + 16;
  174.     WORD( parea + 4 ) = 0;
  175.     EGB_sjisString( egbwork, parea );
  176.  
  177.     for( i = 0; i < strlen( s ); ++i )
  178.     {
  179.         if( iskanji( *( unsigned char * )( s + i ) ) != 0 && iskanji2( *( unsigned char * )( s + i + 1 ) ) != 0 )
  180.         {
  181.             WORD( parea + 0 ) = 2;
  182.             WORD( parea + 2 ) = *( short * )( s + i );
  183.             ++i;
  184.         }
  185.         else
  186.         {    WORD( parea + 0 ) = 1;
  187.             BYTE( parea + 2 ) = *( s + i );
  188.         }
  189.         EGB_connectSjisString( egbwork, parea );
  190.         wait( 0x800, 0 );
  191.     }
  192. }
  193.  
  194.  
  195. void line( int x1, int y1, int x2, int y2, int func, int color, int bf )
  196. {
  197.     int p = 0;
  198.     char parea[ 0x10 ];
  199.  
  200.     EGB_writeMode( egbwork, func );
  201.     if( bf == LINE )
  202.     {    p = 2;
  203.         WORD( parea ) = 2;
  204.     }
  205.     else if( bf == BOX )
  206.         EGB_paintMode( egbwork, 0x0002 );
  207.     else if( bf == BOXFULL )
  208.     {    EGB_paintMode( egbwork, 0x0022 );
  209.         EGB_color( egbwork, 2, color );
  210.     }
  211.     EGB_color( egbwork, 0, color );
  212.  
  213.     WORD( parea + p + 0 ) = x1;
  214.     WORD( parea + p + 2 ) = y1;
  215.     WORD( parea + p + 4 ) = x2;
  216.     WORD( parea + p + 6 ) = y2;
  217.  
  218.     if( bf == LINE )
  219.         EGB_connect( egbwork, parea );
  220.     else
  221.         EGB_rectangle( egbwork, parea );
  222. }
  223.  
  224.  
  225. void clear( int x1, int y1, int x2, int y2, int page, int mode )
  226. {
  227.     int x = ( x1 + x2 ) / 2;
  228.     int y = ( y1 + y2 ) / 2;
  229.     int i, j;
  230.     int xx, yy;
  231.     int vp;
  232.     static int dps[] = { 0, 5, 2, 7, 4, 9, 1, 6, 3, 8 };
  233.  
  234.  
  235.     if( mode == 1 )
  236.     {
  237.         EGB_writePage( egbwork, page );
  238.  
  239.         for( j = 0; j < 3; ++j )
  240.         {    for( i = j; i <= ( ( x > y ) ? x : y ); i += 3 )
  241.             {    if( i <= x - x1 )
  242.                 {    line( x + i, y1, x - i, y2, PSET, 0x8000, LINE );
  243.                     line( x1 + i, y1, x2 - i, y2, PSET, 0x8000, LINE );
  244.                 }
  245.                 if( i <= y - y1 )
  246.                 {    line( x1, y - i, x2, y + i, PSET, 0x8000, LINE );
  247.                     line( x2, y1 + i, x1, y2 - i, PSET, 0x8000, LINE );
  248.                 }
  249.             }
  250.         }
  251.         EGB_writePage( egbwork, 0 );
  252.     }
  253.     else
  254.     {
  255.         for( yy = 0; yy < 10; ++yy )
  256.         {
  257.             for( xx = 0; xx < 10; ++xx )
  258.             {
  259.                 for( y = 0; y < 240; y += 10 )
  260.                 {
  261.                     for( x = 0; x < 320; x += 10 )
  262.                     {
  263.                         vp = ( x + dps[ xx ] ) * 2 + ( y + dps[ yy ] ) * 1024;
  264.                         VRAM_putPixelW( vp + 0x40000, 0 );
  265.                     }
  266.                 }
  267.             }
  268.         }
  269.     }
  270. }
  271.  
  272.  
  273. void egbInit( void )
  274. {
  275.     EGB_init( egbwork, 1536 );
  276.     EGB_resolution( egbwork, 0, 3 );
  277.     EGB_resolution( egbwork, 1, 10 );
  278.     EGB_displayPage( egbwork, 1, 3 );
  279.     EGB_writePage( egbwork, 1 );
  280.     EGB_displayStart( egbwork, 0, 0, 0 );
  281.     EGB_displayStart( egbwork, 2, 2, 2 );
  282.     EGB_displayStart( egbwork, 3, 319, 239 );
  283.     EGB_writePage( egbwork, 0 );
  284. }
  285.  
  286.  
  287. void mouseInit( void )
  288. {
  289.     MOS_start( mousework, 4096 );
  290.     MOS_resolution( 0, 3 );
  291.     MOS_writePage( 0 );
  292.     MOS_horizon( 0, 624 );
  293.     MOS_vertical( 0, 464 );
  294. }
  295.  
  296.  
  297. void graphicDisp( char *fn, int ef, int wf )
  298. {
  299.     int cond;
  300.  
  301.     cond = KYGload( fn, ef, 1 );
  302.     EGB_writePage( egbwork, 0 );
  303.  
  304.     if( wf == ON )
  305.         wait( 0, 0 );
  306. }
  307.  
  308.  
  309. void paletteChange( int n, int g, int r, int b )
  310. {
  311.     char parea[ 0x10 ];
  312.  
  313.     DWORD( parea + 0 ) = 1;
  314.     DWORD( parea + 4 ) = n;
  315.     BYTE( parea + 8 ) = b;
  316.     BYTE( parea + 9 ) = r;
  317.     BYTE( parea + 10 ) = g;
  318.     BYTE( parea + 11 ) = 0;
  319.     EGB_palette( egbwork, 1, parea );
  320. }
  321.  
  322.  
  323. void fade( int pn, int mode )
  324. {
  325.     int i;
  326.     char parea[ 0x10 ];
  327.  
  328.     DWORD( parea + 0 ) = 1;
  329.     DWORD( parea + 4 ) = pn;
  330.     BYTE( parea + 11 ) = 0;
  331.  
  332.     if( mode == 0 )
  333.     {
  334.         for( i = 0; i < 256; i += 4 )
  335.         {
  336.             BYTE( parea + 8 ) = i;
  337.             BYTE( parea + 9 ) = i;
  338.             BYTE( parea + 10 ) = i;
  339.             EGB_palette( egbwork, 1, parea );
  340.             MOS_rdpos( &button, &mouseX, &mouseY );
  341.             if( button != 0 )
  342.                 i += 12;
  343.         }
  344.     }
  345.     else
  346.     {
  347.         for( i = 255; i > 0; i -= 4 )  
  348.         {
  349.             BYTE( parea + 8 ) = i;
  350.             BYTE( parea + 9 ) = i;
  351.             BYTE( parea + 10 ) = i;
  352.             EGB_palette( egbwork, 1, parea );
  353.             MOS_rdpos( &button, &mouseX, &mouseY );
  354.             if( button != 0 )
  355.                 i -= 12;
  356.         }
  357.     }
  358. }
  359.  
  360.  
  361. void triggerOffWait( void )
  362. {
  363.     do
  364.     {    MOS_rdpos( &button, &mouseX, &mouseY );
  365. /*        if( button == 3 )
  366.             fugakuExit();
  367. */
  368.     }
  369.     while( button != 0 );
  370. }
  371.  
  372.  
  373. void wait( unsigned long n, int cf )
  374. {
  375.     unsigned long i;
  376.  
  377.     MOS_disp( cf );
  378.     for( i = 0; ( n == 0 ) || ( i < n ) ; ++i )
  379.     {    MOS_rdpos( &button, &mouseX, &mouseY );
  380.         if( button != 0 )
  381.         {    buttonStack = button;
  382.             triggerOffWait();
  383.             break;
  384.         }
  385.     }
  386.     MOS_disp( 0 );
  387. }
  388.  
  389.  
  390. void fugakuExit( void )
  391. {
  392.     EGB_writePage( egbwork, 1 );
  393.     EGB_clearScreen( egbwork );
  394.     EGB_writePage( egbwork, 0 );
  395.     EGB_clearScreen( egbwork );
  396.     MOS_end();
  397.     exit( 0 );
  398. }
  399.  
  400.